const state = {
  associatedRowList: new Map(), // 已关联Row集合
  showModal: false, // 关联商品（spu维度）模态框开关
}
const mutations = {
  /* 关联 */
  ASSOCIATED_GOODS: (state, data) => {
    let { row, typeList } = data;
    let key = typeList.reduce((value, item) => {
      value += row[item];
      return value;
    }, '');
    state.associatedRowList.set(key, row);
  },
  /* 取消关联 */
  CANCEL_GOODS: (state, data) => {
    let { row, typeList } = data;
    let key = typeList.reduce((value, item) => {
      value += row[item];
      return value;
    }, '');
    state.associatedRowList.delete(key);
  },
  /* 打开或关闭弹框 */
  CHANGE_MODAL_SWITCH: (state, data) => {
    state.showModal = data
  },
  /* 清空 */
  CLEAR_GOODS: (state, data) => {
    state.associatedRowList.clear()
  },
  /* 所有state状态都清空 */
  DESTORY_STATE: (state, data) => {
    state.associatedRowList.clear()
    state.showModal = false
  },
}
export default {
  namespaced: true,
  state,
  mutations
}
